#include<bits/stdc++.h>
using namespace std;
long long n,l,r;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	
	if(r-l+1>=n)
	{
		cout<<n-1<<endl;
	}else{
		long long ma=r%n;
		long long mi=l%n;
		if(ma<mi)cout<<n-1<<endl;
		else cout<<ma<<endl; 
		//cout<<mi<<" "<<ma;	
	}
	return 0;
}
